package com.stores.v1.toolset;

import java.sql.Connection;
import java.sql.SQLException;

public abstract class Database implements IDatabase {

	private String connectionString;
	private String server;
	private String database;
	private String username;
	private String password;
	private String driver;

	/**
	 * @throws DatabaseInitializationException
	 * 
	 */
	public abstract Connection getOpenConnection()
			throws DatabaseInitializationException;

	/**
	 * @throws SQLException
	 * 
	 */
	public void closeConnection(Connection connection) throws SQLException {
		if (!connection.isClosed()) {
			connection.close();
			connection = null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#getDatabaseName()
	 */
	@Override
	public String getDatabaseName() {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#setDatabaseName()
	 */
	@Override
	public void setDatabaseName() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#buildConnectionString()
	 */
	@Override
	public String buildConnectionString() {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#getConnectionString()
	 */
	@Override
	public String getConnectionString() {
		return connectionString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.stores.v1.toolset.IDatabase#setConnectionString(java.lang.String)
	 */
	@Override
	public void setConnectionString(String connectionString) {
		this.connectionString = connectionString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#getServer()
	 */
	@Override
	public String getServer() {
		return server;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#setServer(java.lang.String)
	 */
	@Override
	public void setServer(String server) {
		this.server = server;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#getServer()
	 */
	@Override
	public String getDriver() {
		return driver;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#setServer(java.lang.String)
	 */
	@Override
	public void setDriver(String driver) {
		this.driver = driver;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#getDatabase()
	 */
	@Override
	public String getDatabase() {
		return database;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#setDatabase(java.lang.String)
	 */
	@Override
	public void setDatabase(String database) {
		this.database = database;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#getUsername()
	 */
	@Override
	public String getUsername() {
		return username;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#setUsername(java.lang.String)
	 */
	@Override
	public void setUsername(String username) {
		this.username = username;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#getPassword()
	 */
	@Override
	public String getPassword() {
		return password;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.stores.v1.toolset.IDatabase#setPassword(java.lang.String)
	 */
	@Override
	public void setPassword(String password) {
		this.password = password;
	}
}
